<div class="layuimini-container layuimini-page-anim">
    <div class="layuimini-main">
        <fieldset class="table-search-fieldset">
            <legend>采集设置</legend>
            <div>
                <form class="layui-form layui-form-pane" lay-filter="collectset">

                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">首页缓存</label>
                            <div class="layui-input-inline">
                                <input type="radio" name="indexSw" value="true" title="开启">
                                <input type="radio" name="indexSw" value="false" title="关闭">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">缓存时间</label>
                            <div class="layui-input-inline">
                                <input type="text" name="indexTime" autocomplete="off" placeholder="请输入缓存时间，单位秒"
                                    class="layui-input">
                            </div>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">列表缓存</label>
                            <div class="layui-input-inline">
                                <input type="radio" name="listSw" value="true" title="开启">
                                <input type="radio" name="listSw" value="false" title="关闭">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">缓存时间</label>
                            <div class="layui-input-inline">
                                <input type="text" name="listTime" autocomplete="off" placeholder="请输入缓存时间，单位秒"
                                    class="layui-input">
                            </div>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">详情缓存</label>
                            <div class="layui-input-inline">
                                <input type="radio" name="detailSw" value="true" title="开启">
                                <input type="radio" name="detailSw" value="false" title="关闭">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">缓存时间</label>
                            <div class="layui-input-inline">
                                <input type="text" name="detailTime" autocomplete="off" placeholder="请输入缓存时间，单位秒"
                                    class="layui-input">
                            </div>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">播放缓存</label>
                            <div class="layui-input-inline">
                                <input type="radio" name="playSw" value="true" title="开启">
                                <input type="radio" name="playSw" value="false" title="关闭">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">缓存时间</label>
                            <div class="layui-input-inline">
                                <input type="text" name="playTime" autocomplete="off" placeholder="请输入缓存时间，单位秒"
                                    class="layui-input">
                            </div>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">搜索缓存</label>
                            <div class="layui-input-inline">
                                <input type="radio" name="searchSw" value="true" title="开启">
                                <input type="radio" name="searchSw" value="false" title="关闭">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">播放缓存</label>
                            <div class="layui-input-inline">
                                <input type="text" name="searchTime" autocomplete="off" placeholder="请输入缓存时间，单位秒"
                                    class="layui-input">
                            </div>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">轮播缓存</label>
                            <div class="layui-input-inline">
                                <input type="radio" name="bannerSw" value="true" title="开启">
                                <input type="radio" name="bannerSw" value="false" title="关闭">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">缓存时间</label>
                            <div class="layui-input-inline">
                                <input type="text" name="bannerTime" autocomplete="off" placeholder="请输入缓存时间，单位秒"
                                    class="layui-input">
                            </div>
                        </div>

                    </div>

                    <div class="layui-form-item">
                        <tip>缓存时间单位为秒,永久缓存请填写 0 </tip>
                    </div>

                    <div class="layui-form-item">
                        <button type="button" class="layui-btn" lay-submit="" lay-filter="webset">保存</button>
                    </div>
                </form>
            </div>
        </fieldset>
    </div>


</div>

<script>
    layui.use(['form'], function () {
        var form = layui.form,
            layer = layui.layer;
        /**
         * 初始化表单，要加上，不然刷新部分组件可能会不加载
         */
        form.render();

        //监听提交
        form.on('submit(webset)', function (data) {
            $.ajax({
                url: "/ask/action/system/collectset",
                type: "post",
                timeout: 3000,
                dataType: "json",
                contentType: 'application/x-www-form-urlencoded;charset=utf-8',
                data: data.field,
                success: function (data) {
                    if (data.code == 200) {
                        layer.msg(data.msg, { time: 1500 });
                    } else {
                        layer.msg(data.msg, { time: 1500 });
                    }
                },
                error: function (XMLResponse) {
                    //异常捕获
                    layer.msg(XMLResponse.responseText);
                }
            });
            return false;
        });

        // 页面初始化
        $(document).ready(function () {
            //获取初始信息
            $.post("/v1/admin/data/collectset", function (data, status) {
                //表单初始赋值
                form.val('collectset', data);
            });
        });

    });
</script>